package Thread;
//指令重排序
public class ThreadDemo31 {
    private static volatile boolean flag = false;
    private static int value = 0;

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            value = 10;
            flag = true;
        });

        Thread t2 = new Thread(() -> {
            if (flag) {
                System.out.println("Value: " + value);
            }
        });

        t1.start();
        t2.start();
    }
}
